package com.monster.starter.security.controller;

import com.monster.starter.core.http.request.Request;
import com.monster.starter.security.common.entity.SysRsaInfo;
import com.monster.starter.security.common.entity.SysRsaInfoVo;
import com.monster.starter.security.service.TransmissionCipherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取数据安全的controller层
 * @author kuang
 */
@RestController
@RequestMapping("cipher")
public class CipherController {
    /**
     * 传输密钥管理
     */
    @Autowired
    private TransmissionCipherService cipherService;

    /**
     * 获取一组密钥信息
     * @return 返回密钥信息
     */
    @Request(sign = false)
    @RequestMapping("get")
    public SysRsaInfoVo get () {
        SysRsaInfoVo vo = new SysRsaInfoVo();
        SysRsaInfo info = cipherService.get();
        vo.setCode(info.getCode());
        vo.setPrivateCipher(info.getCPrivateCipher());
        vo.setPublicCipher(info.getSPublicCipher());
        return  vo;
    }

}
